#include <stdio.h>

int main( )
{
    int n, m;
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        if ( n == 0 && m == 0 ) break;
        int a, b;
        bool space = false;
        for ( a = 0; a < 10; a++ )
            for ( b = 0; b < 10; b++ )
            {
                if ( ( n * 100 + a * 10 + b ) % m == 0 )
                {
                    if ( space )
                        printf(" ");
                    else
                        space = true;
                    printf("%d%d", a, b);
                }
            }
        printf("\n");
    }
    return 0;
}
